import {
  MonitorCog,
  Info,
  SquareSigma,
  Mail,
  Calculator,
  Club,
  Haze,
  Pill,
  ShieldX,
  SunMoon,
  Bell,
  Settings,
  Users,
  BookUser,
  ImageDown,
  FileKey,
  User,
  UserPen,
  List,
  LayoutDashboard,
  LayoutList,
  LucideIcon,
  MenuIcon,
  MessagesSquare,
  AppWindow,
  ChartBarDecreasing,
  Waypoints,
  ListOrdered,
  ScrollText,
} from "lucide-react";
import React, { lazy } from "react";

// 声明类型
export interface SyncRoute {
  path: string;
  component: React.LazyExoticComponent<React.FC<any>>;
  children?: Array<SyncRoute>;
  meta?: {
    needLogin?: boolean;
    isMenu?: boolean;
    title?: string;
    icon?: LucideIcon;
    subject?: string;
    method?: string;
  };
}

const RouteTable: Array<SyncRoute> = [
  {
    path: "/login", //
    component: lazy(() => import("@/pages/login")),
  },
  {
    path: "/sign-in", //
    component: lazy(() => import("@/pages/auth/sign-in")),
  },
  {
    path: "/sign-in-2", //
    component: lazy(() => import("@/pages/auth/sign-in-2")),
  },
  {
    path: "/sign-up", //
    component: lazy(() => import("@/pages/auth/sign-up")),
  },
  {
    path: "/forgot-password", //
    component: lazy(() => import("@/pages/auth/forgot-password")),
  },
  {
    path: "/otp", //
    component: lazy(() => import("@/pages/auth/otp")),
  },
  {
    path: "/cmp", //
    component: lazy(() => import("@/pages/component-controll")),
  },
  // Main routes
  {
    path: "/user", //
    component: lazy(() => import("@/components/app-shell")),
    meta: {
      needLogin: true,
      isMenu: false,
      title: "用户信息",
      icon: Info,
    },
    children: [
      {
        path: "/user/profile", //
        component: lazy(() => import("@/pages/settings/profile")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "个人信息",
          icon: UserPen,
        },
      },
    ],
  },
  {
    path: "/", //
    component: lazy(() => import("@/components/app-shell")),
    meta: {
      needLogin: false,
      isMenu: true,
      title: "药学信息",
      icon: Info,
    },
    children: [
      // {
      //   path: "/", //
      //   component: lazy(() => import("@/pages/dashboard")),
      //   meta: {
      //     needLogin: true,
      //     isMenu: true,
      //     title: "看板",
      //     icon: LayoutDashboard,
      //   },
      // },
      {
        path: "/", //
        component: lazy(() => import("@/pages/his-medicines")),
        meta: {
          needLogin: false,
          isMenu: true,
          title: "HIS药品管理",
          icon: Pill,
        },
      },
      {
        path: "/medicines/info", //
        component: lazy(() => import("@/pages/his-medicines")),
        meta: {
          needLogin: false,
          isMenu: false,
          title: "HIS药品管理-",
          icon: Pill,
        },
      },
      {
        path: "/medicine/info/:id", //
        component: lazy(() => import("@/pages/his-medicine-detail")),
        meta: {
          needLogin: false,
          isMenu: false,
          title: "HIS药品详情",
          icon: UserPen,
        },
      },
    ],
  },
  {
    path: "/vbp/", //
    component: lazy(() => import("@/components/app-shell")),
    meta: {
      needLogin: true,
      isMenu: true,
      title: "集采药品管理",
      icon: Mail,
      subject: "search_vbp_dept_duty_sql",
      method: "{'GET'}",
    },
    children: [
      {
        path: "/vbp/stats-d3", //
        component: lazy(() => import("@/pages/vbp-stats-d3")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "汇总统计",
          icon: ChartBarDecreasing,
          subject: "stats_by_his_code",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/hiscode-d3", //
        component: lazy(() => import("@/pages/vbp-hiscode-d3")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "中选药品完成情况",
          icon: ChartBarDecreasing,
          subject: "stats_by_his_code",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/cadn-d3", //
        component: lazy(() => import("@/pages/vbp-cadn-d3")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "按通用名分组完成情况",
          icon: ChartBarDecreasing,
          subject: "stats_by_cadn",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/cadn-vbp-d3", //
        component: lazy(() => import("@/pages/vbp-cadn-vbp-d3")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "某通用名和集采类别各科完成情况",
          icon: ChartBarDecreasing,
          subject: "stats_by_cadn_vbp",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/dept-d3", //
        component: lazy(() => import("@/pages/vbp-dept-d3")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "科室中选品种完成情况",
          icon: ChartBarDecreasing,
          subject: "stats_by_dept",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/batches", //
        component: lazy(() => import("@/pages/vbp-batches")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "批次管理",
          icon: ListOrdered,
          subject: "update_vbp_batch",
          method: "{'PUT'}",
        },
      },
      {
        path: "/vbp/dept-duty-calc", //
        component: lazy(() => import("@/pages/vbp-dept-duty-calc")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "科室任务分配",
          icon: Calculator,
          subject: "update_vbp_dept_duty",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/dept-duty", //
        component: lazy(() => import("@/pages/vbp-dept-duty")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "科室任务管理",
          icon: ScrollText,
          subject: "search_vbp_dept_duty_sql",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/stats", //
        component: lazy(() => import("@/pages/vbp-day-stats")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "每日统计导入",
          icon: SquareSigma,
          subject: "search_vbp_day_stats",
          method: "{'GET'}",
        },
      },
      {
        path: "/vbp/access-log-stats", //
        component: lazy(() => import("@/pages/access_logs")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "集采访问统计",
          icon: SquareSigma,
          subject: "search_access_log_sql",
          method: "{'GET'}",
        },
      },
    ],
  },
  {
    path: "/settings",
    component: lazy(() => import("@/components/app-shell")),
    meta: {
      needLogin: true,
      isMenu: true,
      title: "设置",
      icon: Settings,
      subject: "update_user",
      method: "{'PUT'}",
    },
    children: [
      {
        path: "/settings/tenants", //
        component: lazy(() => import("@/pages/tenants")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "中心管理",
          icon: Club,
          subject: "update_tenant",
          method: "{'PUT'}",
        },
      },
      {
        path: "/settings/roles", //
        component: lazy(() => import("@/pages/roles")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "角色管理",
          icon: BookUser,
          subject: "update_role",
          method: "{'PUT'}",
        },
      },
      {
        path: "/settings/users", //
        component: lazy(() => import("@/pages/users")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "用户管理",
          icon: Users,
          subject: "update_user",
          method: "{'PUT'}",
        },
      },
      {
        path: "/settings/account", //
        component: lazy(() => import("@/pages/settings/account")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "账号",
          icon: Users,
          subject: "secret",
        },
      },
      {
        path: "/settings/appearance", //
        component: lazy(() => import("@/pages/settings/appearance")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "皮肤",
          icon: SunMoon,
          subject: "secret",
        },
      },
      {
        path: "/settings/notifications", //
        component: lazy(() => import("@/pages/settings/notifications")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "提醒",
          icon: Bell,
          subject: "secret",
        },
      },
      {
        path: "/settings/display", //
        component: lazy(() => import("@/pages/settings/display")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "显示",
          icon: MonitorCog,
          subject: "secret",
        },
      },
      {
        path: "/settings/error-example",
        component: lazy(() => import("@/pages/settings/error-example")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "错误",
          icon: ShieldX,
          subject: "secret",
        },
      },
    ],
  },
  {
    path: "/playground",
    component: lazy(() => import("@/components/app-shell")),
    meta: {
      needLogin: true,
      isMenu: true,
      title: "探索",
      icon: Haze,
      subject: "secret",
    },
    children: [
      {
        path: "/playground/date-picker", //
        component: lazy(() => import("@/pages/playground/date-picker-form")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "日期表单",
          icon: List,
        },
      },
      {
        path: "/playground/tasks", //
        component: lazy(() => import("@/pages/tasks")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "任务",
          icon: List,
        },
      },
      {
        path: "/playground/apps", //
        component: lazy(() => import("@/pages/apps")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "应用",
          icon: AppWindow,
        },
      },
      {
        path: "/playground/analysis", //
        component: lazy(() => import("@/components/coming-soon")),
        meta: {
          needLogin: true,
          isMenu: false,
          title: "数据分析",
          icon: ChartBarDecreasing,
        },
      },
      {
        path: "/playground/chat", //
        component: lazy(() => import("@/pages/chat")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "药学咨询",
          icon: MessagesSquare,
        },
      },
      {
        path: "/playground/chats", //
        component: lazy(() => import("@/pages/chat_test/index")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "药学咨询-测试",
          icon: MessagesSquare,
        },
      },
      {
        path: "/playground/extra-components",
        component: lazy(() => import("@/components/coming-soon")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "其他",
          icon: Waypoints,
        },
      },
      {
        path: "/playground/got-ocr", //
        component: lazy(() => import("@/pages/got_ocr")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "OCR",
          icon: ImageDown,
        },
      },
      {
        path: "/playground/knowledge-graph", //
        component: lazy(() => import("@/pages/knowledge_graph")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "知识图谱示例",
          icon: UserPen,
        },
      },
      {
        path: "/playground/graph-query", //
        component: lazy(() => import("@/pages/graph_query")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "知识图谱查询",
          icon: UserPen,
        },
      },
      {
        path: "/playground/editor", //
        component: lazy(() => import("@/pages/lexical")),
        meta: {
          needLogin: true,
          isMenu: true,
          title: "Lexical-Editor",
          icon: UserPen,
        },
      },
    ],
  },
  // Error routes
  {
    path: "/500", //
    component: lazy(() => import("@/pages/errors/general-error")),
  },
  {
    path: "/404", //
    component: lazy(() => import("@/pages/errors/not-found-error")),
  },
  {
    path: "/503", //
    component: lazy(() => import("@/pages/errors/maintenance-error")),
  },
  {
    path: "/401", //
    component: lazy(() => import("@/pages/errors/unauthorised-error")),
  },

  // Fallback 404 route
  {
    path: "*", //
    component: lazy(() => import("@/pages/errors/not-found-error")),
  },
];

export default RouteTable;
